//https://www.bilibili.com/video/BV1ne411D7CQ/?spm_id_from=333.337.search-card.all.click&vd_source=4ec910f05eea76e8fe7255f381962332
//https://leetcode.cn/problems/longest-increasing-subsequence/?envType=study-plan-v2&envId=top-100-liked
//https://github.com/fuxuemingzhu/Leetcode-Solution-All/blob/main/300-399/300.%20Longest%20Increasing%20Subsequence%20%E6%9C%80%E9%95%BF%E9%80%92%E5%A2%9E%E5%AD%90%E5%BA%8F%E5%88%97.md


#include <vector>
#include <stack>
#include <list>
#include <map>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <iostream>

using namespace std;
//最长递增子序列.cpp
//给你一个整数数组，找到其中最长严格递增子序列的长度。
//双层for+dp；

class Solution {
public:
    int lengthOfLIS(vector<int>& nums) {
        int n = (int)nums.size();
        if (n == 0) {
            return 0;
        }
        vector<int> dp(n, 0);
        for (int i = 0; i < n; ++i) {
            dp[i] = 1;
            for (int j = 0; j < i; ++j) {
                if (nums[j] < nums[i]) {
                    dp[i] = max(dp[i], dp[j] + 1);
                }
            }
        }
        return *std::max_element(dp.begin(), dp.end());
    }
};